package xyz.riceball.develop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import xyz.riceball.develop.entity.po.AssistSearchPO;
import xyz.riceball.develop.service.AssistSearchService;
import xyz.riceball.framework.core.annotation.RbSysRequest;
import xyz.riceball.framework.core.bean.ApiController;
import xyz.riceball.framework.core.bean.ApiR;
import xyz.riceball.framework.core.bean.ApiRc;
import xyz.riceball.framework.core.bean.PageParam;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;


/**
 * 辅助缓存 控制层
 *
 * @author xiaovcloud
 * @since 2022-07-02 10:58:37
 */
@Deprecated
@RestController
//@Api(tags = "辅助查询管理")
@RequestMapping("/rb/api/develop/assistSearch")
public class AssistSearchController extends ApiController {

    @Resource
    private AssistSearchService assistSearchService;

    /**
     * 分页查询所有数据
     *
     * @param pageParam 分页对象
     * @param assistSearchPO    查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询辅助查询")
    @GetMapping
    public ApiR<Page<AssistSearchPO>> selectPage(PageParam pageParam, AssistSearchPO assistSearchPO) {
        return success(assistSearchService.selectPage(PageParam.of(pageParam), assistSearchPO));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询辅助查询")
    @GetMapping("{id}")
    public ApiR<AssistSearchPO> selectOne(@PathVariable Serializable id) {
        return success(assistSearchService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param assistSearchPO 实体对象
     * @return 新增结果
     */
    @ApiOperation(value = "新增辅助查询")
    @PostMapping
    public ApiR<AssistSearchPO> insert(@RequestBody AssistSearchPO assistSearchPO) {
        return assistSearchService.add(assistSearchPO);
    }

    /**
     * 修改数据
     *
     * @param assistSearchPO 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改辅助查询")
    @PutMapping
    public ApiR<Void> update(@RequestBody AssistSearchPO assistSearchPO) {
        boolean edit = assistSearchService.edit(assistSearchPO);
        return ApiR.msg(edit, "修改菜单成功", "修改菜单失败");
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @ApiOperation(value = "删除辅助查询")
    @DeleteMapping
    public ApiRc<Void> delete(@RequestBody List<String> ids) {
        return assistSearchService.delete(ids);
    }


}
